package dataextraction;

import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

import util.ConfigurationBean;

public class EntriesTXTExporter extends AbstractEntriesExporter{

	private static EntriesTXTExporter instance;

	private EntriesTXTExporter() {
		
	}
	 
	public static EntriesTXTExporter getInstance() {
		if (EntriesTXTExporter.instance == null) {
			EntriesTXTExporter.instance = new EntriesTXTExporter();
		}
		return EntriesTXTExporter.instance;
	}

	public void exporter(List<Entry> entries, String file_path) throws IOException{
		
		Boolean decorarPalavraChave = Boolean.valueOf(ConfigurationBean.getInstance().get(ConfigurationBean.DECORAR_PALAVRAS_CHAVES_KEY));
		
		StringBuffer content = new StringBuffer(); 
		
		for(Entry entry : entries){
			String title = entry.getDocumentTitle();
			String abstractDocument = entry.getPublicationAbstract();
			
			if(decorarPalavraChave){
				title = entry.getDocumentTitleTagged();
				abstractDocument = entry.getPublicationAbstractTagged();
			}
			
			content.append(entry.getId()+" \t "+
					entry.getNumberOfPages()+" \t "+title+" \t "
					+abstractDocument+" \t "+entry.getPdfLink()+" \t "
					+entry.getPreCriteria()/*+" \t "+entry.getPublisher()*/+" \n");
		}
		FileWriter fw = new FileWriter(file_path,false);
		             
        fw.write(content.toString());              
        fw.close(); 
	}

	public static void main(String[] args) {
		System.out.println("\n              Performance and energy measurements using several NAS, LLNL and ANL benchmarks on the Linux cluster provide several conclusions. First, although batch scheduling is currently used in most clusters, the blocking-based coscheduling techniques such as SB, CC and HYBRID and the gang scheduling can provide much better performance even in a dedicated cluster platform. Second, in contrast to some of the prior studies, we observe that blocking-based schemes like SB and HYBRID can provide better performance than spin-based techniques like PB on a Linux platform. Third, the proposed HYBRID scheduling provides the best performance-energy behavior and can be implemented on any cluster with little effort. All these results suggest that blocking-based coscheduling techniques are viable candidates to be used in clusters for significant performance-energy benefits.".trim());
	}
	
}
